﻿using RAP.Framework.Libary.Utils;
using RAP.Framework.Libary.DomTemplateBuilder.Interface;

namespace RAP.Framework.Libary.DomTemplateBuilder.Handler.Conditional
{
	/// <summary>
	/// 判断是否为Empty的Handler（集合元素个数为0或字符串为空返回true）
	/// </summary>
	public class IsEmptyHandler : ConditionalHandler
    {
		/// <summary>
		/// 对属性值进行判断
		/// </summary>
		/// <param name="propertyValue"></param>
		/// <param name="rootParamObject"></param>
		/// <param name="parentParamObject"></param>
		/// <param name="context"></param>
		/// <returns></returns>
		protected override bool DoCompareValue ( object propertyValue, object rootParamObject, object parentParamObject, ITemplateRenderContext context )
		{
			if ( propertyValue == null )
			{
				return false;
			}
			return propertyValue.IsNullOrEmpty ( );
		}
    }
}
